% 将fjs文件数据格式化
function [ ] = create(sfilepath,tfilepath)
% 读取数据
fidin=fopen(sfilepath);
x = fscanf(fidin,'%f');

% 获取工件数目、机器数目、每个工件的工序数目、每个工序在各台机器上的加工时间
num_job = x(1); % 工件数目
num_machine = x(2); % 机器数目
num_op = zeros(1,num_job);  % 每个工件的工序数目
operation_machine=cell(1,num_job);
operation_time = cell(1,num_job); 

k = 4;  % 下次开始读数据的下标

for i = 1:num_job
    num_op(1,i) = x(k); % 工件 i 的工序数目
    k = k + 1;
    operation_machine_=cell(1,num_op(i));
    operation_time_ = cell(1,num_op(i));
    for j = 1:num_op(1,i)
        num_machine_opij = x(k); % 工件 i 的工序 j 可加工机器数目
        k = k + 1;
        for l = 1:num_machine_opij
            if l==1
                operation_machine_{1,j}=x(k);
            else
                kk=[operation_machine_{1,j},x(k)];
                operation_machine_{1,j}=kk; 
            end
            k = k + 1;
            if l==1
                operation_time_{1,j}=x(k);
            else
                kk=[operation_time_{1,j},x(k)];
                operation_time_{1,j}=kk;
            end
            k = k + 1;
        end
    end
    operation_machine{1,i} = operation_machine_;
    operation_time{1,i} = operation_time_;
end

% 保存文件到tfilepath
save(tfilepath,'num_job','num_machine','num_op','operation_machine','operation_time');
end
